using System;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using Granite.Commons.Metadata;

namespace LeadTracker.Models
{
	public class EditorModel : global::Granite.Modeling.ChangeTrackingModelBase
	{
		public EditorModel()
		{

		}

		public EditorModel(IDictionary<string, object> fields)
		{
			Load(fields);
		}

		[Action("Select")]
		[Action("Delete")]
		public int? EditorKey
		{
			get { return GetOrDefault<int?>("EditorKey"); }
		}

		[Action("Insert")]
		[Action("Update")]
		[Required]
		[StringLength(100)]
		public string UserName
		{
			get { return GetOrDefault("UserName", ""); }
			set { SetValue("UserName", value); }
		}

		[Action("Insert")]
		[Action("Update")]
		[StringLength(100)]
		public string FirstName
		{
			get { return GetOrDefault("FirstName", ""); }
			set { SetValue("FirstName", value); }
		}

		[Action("Insert")]
		[Action("Update")]
		[StringLength(100)]
		public string LastName
		{
			get { return GetOrDefault("LastName", ""); }
			set { SetValue("LastName", value); }
		}

		[Action("Insert")]
		[Action("Update")]
		[Required]
		[StringLength(508)]
		public string EmailAddress
		{
			get { return GetOrDefault("EmailAddress", ""); }
			set { SetValue("EmailAddress", value); }
		}

		[Action("Insert")]
		[Action("Update")]
		public bool IsEnabled
		{
			get { return GetOrDefault<bool>("IsEnabled"); }
			set { SetValue("IsEnabled", value); }
		}


		public override string ToString()
		{
			return FullName;
		}

		[CalculatedField("FirstName,LastName")]
		public string FullName
		{
			get { return FirstName + " " + LastName; }
		}

	}
}
